package com.gonsin.gview.example.gview;

import com.gonsin.gview.annotations.GContext;
import com.gonsin.gview.model.IViewPermissionHandler;
import org.springframework.stereotype.Component;

/**
 * 用于控制按钮的显示和隐藏
 */
@Component
public class PermissionSampleHandler implements IViewPermissionHandler {

    @Override
    public boolean handPermissions(GContext context, String[] permissions, Object model) {
        if (context.getSession() != null){
            // 获取权限列表
//            List<String> permissions = (List<String>) context.getSession().getAttribute("permissions");
//            return permissions.contains(buttonModel.getPermission());

            // 直接返回false，测试权限不可用
            return false;
        }
        return true;
    }
}
